//
//  GroupTableDemoViewController.m
//  etionUI
//
//  Created by wangjian on 8/12/13.
//
//

#import "GroupTableDemoViewController.h"

@interface CGroupTableDemoViewController ()

@end

@implementation CGroupTableDemoViewController

static BOOL isReload = NO;

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self createNavigationBar:@"test" leftBtnText:@"return" rightBtnText:@"function"];
	// Do any additional setup after loading the view.
    
    self.groupTableView.frame = CGRectMake(0, _navBar.bottom, self.view.width, self.view.height-_navBar.bottom);
    [self.groupTableView reloadData];
}

- (void)barRightBtnClick:(id)sender
{
    isReload = !isReload;
    [self.groupTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:2 inSection:0], [NSIndexPath indexPathForRow:0 inSection:1], nil] withRowAnimation:UITableViewRowAnimationAutomatic complete:^(BOOL finished)
    {
        
    }];
}

#pragma mark group table delegate

- (NSUInteger)numberOfGroupInGroupTableView:(CGroupTableView *)groupTableView
{
    return 4;
}

- (NSInteger)groupTableView:(CGroupTableView *)groupTableView numberOfRowsInGroup:(NSInteger)group
{
    return 5;
}

- (CGFloat)groupTableView:(CGroupTableView *)groupTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (isReload == YES)
    {
        return 80;
    }
    return 44;
}

- (CGroupTableViewCell *)groupTableView:(CGroupTableView *)groupTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGroupTableViewCell *cell = [[[CGroupTableViewCell alloc] initWithFrame:CGRectZero] autorelease];
    cell.titleLable.text = [NSString stringWithFormat:@"Group %lu Row %lu", indexPath.section, indexPath.row];
    [cell setBackgroundViewWithInversionableImage:[[UIImage imageNamed:@"gtv_cell_bg_blue.png"] resizeableCenterImage]];
    return cell;
//    return [[self.groups objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
}

- (void)groupTableView:(CGroupTableView *)groupTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

}

@end
